// [[ OnflowGenerator Entity UUID: c1b1ff567c4340698cd215a691137c91 ]]
package com.itdct.onflow.system.log.entity

import com.baomidou.mybatisplus.annotation.TableName
import com.itdct.onflow.core.annotation.Column
import com.itdct.onflow.core.annotation.ColumnRelateDict
import com.itdct.onflow.core.annotation.ColumnRelateId
import com.itdct.onflow.core.annotation.TableDescription
import com.itdct.onflow.core.entity.IdEntity
import com.itdct.onflow.system.account.entity.SysAccountEntity
import com.itdct.onflow.system.api.entity.SysApiEntity
import java.math.BigDecimal
import java.util.*

/**
 * @author Zhouwx
 * @date 2025/8/25 13:58:32
 * @version 1.0
 * @description
 */
@TableDescription("系统重要接口访问日志")
@TableName("sys_important_api_log")
class SysImportantApiLogEntity : IdEntity() {
    @ColumnRelateId(targetClass = SysAccountEntity::class, targetFieldName = "name")
    @Column(comment = "账号id", nullable = true, indexed = true, sort = 10)
    var accountId: Long? = null

    @Column(comment = "请求时间", nullable = false, sort = 20)
    var requestTime: Date? = null

    @Column(comment = "响应时间", nullable = false, sort = 30)
    var responseTime: Date? = null

    @Column(comment = "处理时间", length = 10, decimal = 2, nullable = false, sort = 40)
    var handleTime = BigDecimal(0)

    @Column(comment = "实例id", nullable = false, length = 100, defaultValue = "1", indexed = true, sort = 50)
    var instanceId = ""

    @Column(comment = "接口地址", nullable = false, length = 500, sort = 60)
    var url = ""

    @ColumnRelateId(targetClass = SysApiEntity::class, targetFieldName = "name")
    @Column(comment = "接口id", nullable = false, sort = 70)
    var apiId = 0L

    @Column(comment = "返回码", nullable = false, sort = 80)
    var returnCode = 0

    @Column(comment = "来源ip", nullable = false, length = 64, sort = 90)
    var sourceIp = ""

    @ColumnRelateDict(dictCode = "platformType")
    @Column(comment = "平台类型", nullable = false, length = 100, defaultValue = "onflow-backend", indexed = true, sort = 100)
    var platformType = ""

    @Column(comment = "失败原因", nullable = true, length = 5000, sort = 110)
    var failReason = ""

    @Column(comment = "请求参数", nullable = false, length = 10000, sort = 120)
    var requestBody = ""

    @Column(comment = "返回参数", nullable = false, length = 10000, sort = 130)
    var responseBody = ""

}